//
//  DoctorListModel.m
//  QuickCure
//
//  Created by Cyan on 16/9/12.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "DoctorListModel.h"
#import "NetWorkTool.h"
#import "NetWorkDefine.h"


@implementation DoctorListModel


#pragma mark - 快速创建对象方法
+ (instancetype)modelWithDictionary:(NSDictionary *)dic{
    
    DoctorListModel *model = [[DoctorListModel alloc] init];
    
    [model setValuesForKeysWithDictionary:dic];
    
    return model;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key{}


#pragma mark - 网络获取数据
/**
 *  获取用户关注医生的数据
 *
 *  @return 返回用户关注医生的数据模型数组
 */
+ (void)doctorListWithSuccess:(void(^)(NSArray <DoctorListModel *>*))successBlcok error:(void(^)(NSError *error))errorBlock{
    // 获取关注医生的接口
    NSString *urlString = kDoctorListUrl;
    
    // 用户信息
    NSDictionary *paramDic = @{
                               @"user_id":@"1000089",
                               @"page_size":@15,
                               @"page":@1
                               };
    // 网络请求
    [[NetWorkTool shareManager] POST_RequestWithUrlString:urlString
                                                   parmas:paramDic
                                            successBloock:^(NSDictionary *responseObject) {
                                                
                                                // json 反序列化
                                                NSArray<NSDictionary *> *dataArray = responseObject[@"data"];
                                                
                                                NSMutableArray *newArray = [NSMutableArray array];
                                                [dataArray enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                                                    
                                                    DoctorListModel *model = [DoctorListModel modelWithDictionary:obj];
                                                    [newArray addObject:model];
                                                }];
                                                if (successBlcok) {
                                                    successBlcok(newArray);
                                                }
                                                
                                            }
                                             failureBlock:^(NSError *error) {
                                                 if (errorBlock) {
                                                     errorBlock(error);
                                                 }
                                             }];
    
}
 #pragma mark - 自定义描述方法
- (NSString *)description {
    
    /**
     *  doctor_gender = 1;
     doctor_id = 200000100;
     hospital_name = 北京协和医院;
     doctor_portrait = http://iosapi.itcast.cn/image/elarge_0ce52dde-3551-4086-bd6f-3421838e319d.jpg;
     flower = 1;
     doctor_title_id = 0;
     doctor_title_name = 其他;
     banner = 1;
     doctor_name = 姜伟;
     easymob_id = <null>;
     doctor_attention_id = 148;
     hospital_id = 1;
     operation_count = 1;
     
     */
    return [NSString stringWithFormat:@"%@\ndoctor_gender = %d\ndoctor_id = %@\nhospital_name = %@\ndoctor_portrait = %@\nflower = %@\ndoctor_title_id = %@\ndoctor_title_name = %@\nbanner = %@\ndoctor_name = %@\neasymob_id = %@\ndoctor_attention_id = %@\nhospital_id = %@\noperation_count = %@",[super description],self.doctor_gender,self.doctor_id,self.hospital_name,self.doctor_portrait,self.flower,self.doctor_title_id,self.doctor_title_name,self.banner,self.doctor_name,self.easymob_id,self.doctor_attention_id,self.hospital_id,self.operation_count];
    
    
}

@end
